<?php


namespace app\admin\controller;


use think\Controller;

class Connect extends Controller
{
    public function index()
    {
        $connect = db("connect")->select();
        $this->assign([
            'connect' => $connect,
            'total' => count($connect)
        ]);
        return view("index");
    }
    public function editStatusStart()
    {
        $id = input("id");
        $res = db("connect")->where("id",$id)->update(['state' => 1]);
        if(!$res) return -1;
        return 200;
    }
    public function editStatusClose()
    {
        $id = input("id");
        $res = db("connect")->where("id",$id)->update(['state' => 0]);
        if(!$res) return -1;
        return 200;
    }
    public function delete()
    {
        $id = input("id");
        $res = db("connect")->where("id",$id)->delete();
        if($res){
            return ['code' => 200,'msg' => '删除成功'];
        }else{
            return ['code' => -1,'msg' => '删除失败'];
        }
    }

}